package com.cashmama.market.api.infras.enums.order;

/**
 * 请求类型
 * @Author frank
 * @Date 2017/7/25 0025 下午 3:39
 */
public enum AppRequestTypeEnum {
    ANDRIOD(1, "android"),
    IOS(2, "iphone"),
    WAP(3, "h5");

    private Integer code;
    private String desc;

    AppRequestTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public AppRequestTypeEnum setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public AppRequestTypeEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static String getDesc(Integer code) {
        String desc = "";
        for (AppRequestTypeEnum enums : AppRequestTypeEnum.values()) {
            if (enums.getCode() == code) {
                desc = enums.getDesc();
                break;
            }
        }
        return desc;
    }

    public static Integer getCode(String desc) {
        Integer code = null;
        for (AppRequestTypeEnum enums : AppRequestTypeEnum.values()) {
            if (enums.getDesc().equals(desc)) {
                code = enums.getCode();
                break;
            }
        }
        return code;
    }

    public static AppRequestTypeEnum getByDesc(String desc) {
        AppRequestTypeEnum appRequestTypeEnum = null;
        for (AppRequestTypeEnum enums : AppRequestTypeEnum.values()) {
            if (enums.getDesc().equals(desc)) {
                appRequestTypeEnum = enums;
                break;
            }
        }
        return appRequestTypeEnum;
    }
}
